import React from "react";
import { Button, Layout, Table } from "antd";
import styles from './index.module.less'
const { Header, Content } = Layout
const incomeStatist = () => {
    const autoColumns = (list) => {
        if (!list) return
        const columns = [
            {
                title: '类别（粗）',
                dataIndex: 'rough_layer',
                key: 'rough_layer',
                onCell: (_, index) => {
                    const groupSize = 5;
                    const groupStart = Math.floor(index / groupSize) * groupSize;
                    if (index >= groupStart && index < groupStart + groupSize) {
                        return {
                            rowSpan: index === groupStart ? groupSize : 0
                        };
                    }
                    return { rowSpan: 0 };
                }
            },
            {
                title: '类别（细）',
                dataIndex: 'detailed_layer',
                key: 'detailed_layer'
            },
            ...Object.keys(list[0]).filter(key => !(key === 'detailed_layer') && !(key === 'rough_layer')).map(key => {
                return {
                    title: key,
                    dataIndex: key,
                    key
                }
            })
        ]
        return columns
    }
    const data = [
        {
            "rough_layer": "放款额",
            "detailed_layer": "合计",
            "2025-01-01": 31073321136.799995,
            "2025-02-01": 26935724051,
            "2025-03-01": 226200000000,
            "2025-04-01": 180000000000,
            "2025-05-01": 226800000000,
            "2025-06-01": 2271000000005,
            "2025-07-01": 227400000000,
            "2025-08-01": 2277000000000,
            "2025-09-01": 228000000000,
            "2025-10-01": 228300000000,
            "2025-11-01": 228600000000,
            "2025-12-01": 228900000000
        },
        {
            "rough_layer": "放款额",
            "detailed_layer": "自营",
            "2025-01-01": 19312289760.1,
            "2025-02-01": 17547967558.5,
            "2025-03-01": 85747430089.24,
            "2025-04-01": 87369710105.88,
            "2025-05-01": 85046910765.61,
            "2025-06-01": 91463714178.45,
            "2025-07-01": 73039925590.21,
            "2025-08-01": 218337689706.61,
            "2025-09-01": 80567836153.95,
            "2025-10-01": 83281380661.59,
            "2025-11-01": 81324595978.49,
            "2025-12-01": 83218957641.73
        },
        {
            "rough_layer": "放款额",
            "detailed_layer": "助贷-主导",
            "2025-01-01": -3836017388.2,
            "2025-02-01": -4098549698,
            "2025-03-01": -10347430089.24,
            "2025-04-01": -27369710105.88,
            "2025-05-01": -9446910765.61,
            "2025-06-01": -15763714178.45,
            "2025-07-01": 2760074409.79,
            "2025-08-01": 540662310293.39,
            "2025-09-01": -4567836153.95,
            "2025-10-01": -7181380661.59,
            "2025-11-01": -5124595978.49,
            "2025-12-01": -6918957641.73
        },
        {
            "rough_layer": "放款额",
            "detailed_layer": "助贷-辅助",
            "2025-01-01": 120776393,
            "2025-02-01": 36888330,
            "2025-03-01": 75400000000,
            "2025-04-01": 60000000000,
            "2025-05-01": 75600000000,
            "2025-06-01": 75700000000,
            "2025-07-01": 75800000000,
            "2025-08-01": 759000000000,
            "2025-09-01": 76000000000,
            "2025-10-01": 76100000000,
            "2025-11-01": 76200000000,
            "2025-12-01": 76300000000
        },
        {
            "rough_layer": "放款额",
            "detailed_layer": "主导小计",
            "2025-01-01": 15476272371.9,
            "2025-02-01": 13449417860.5,
            "2025-03-01": 75400000000,
            "2025-04-01": 60000000000,
            "2025-05-01": 75600000000,
            "2025-06-01": 75700000000,
            "2025-07-01": 75800000000,
            "2025-08-01": 759000000000,
            "2025-09-01": 76000000000,
            "2025-10-01": 76100000000,
            "2025-11-01": 76200000000,
            "2025-12-01": 76300000000
        },
        {
            "rough_layer": "放款APR",
            "detailed_layer": "合计",
            "2025-01-01": 79.78,
            "2025-02-01": 75.92,
            "2025-03-01": -54.51,
            "2025-04-01": 4.56,
            "2025-05-01": -62.63,
            "2025-06-01": -31.19,
            "2025-07-01": 270.04,
            "2025-08-01": 58.56,
            "2025-09-01": -164.22,
            "2025-10-01": -94.31,
            "2025-11-01": -142.94,
            "2025-12-01": -98.03
        },
        {
            "rough_layer": "放款APR",
            "detailed_layer": "自营",
            "2025-01-01": 15.7,
            "2025-02-01": 15.48,
            "2025-03-01": 3.27,
            "2025-04-01": 2.86,
            "2025-05-01": 3.34,
            "2025-06-01": 3.48,
            "2025-07-01": 2.88,
            "2025-08-01": 13.18,
            "2025-09-01": 3.57,
            "2025-10-01": 3.35,
            "2025-11-01": 3.57,
            "2025-12-01": 3.47
        },
        {
            "rough_layer": "放款APR",
            "detailed_layer": "助贷-主导",
            "2025-01-01": 25.83,
            "2025-02-01": 24.31,
            "2025-03-01": -86.58,
            "2025-04-01": -28.8,
            "2025-05-01": -94.77,
            "2025-06-01": -65.77,
            "2025-07-01": 242.36,
            "2025-08-01": 16.58,
            "2025-09-01": -196.59,
            "2025-10-01": -126.46,
            "2025-11-01": -175.31,
            "2025-12-01": -130.3
        },
        {
            "rough_layer": "放款APR",
            "detailed_layer": "助贷-辅助",
            "2025-01-01": 25.06,
            "2025-02-01": 23.34,
            "2025-03-01": 13.2,
            "2025-04-01": 13.2,
            "2025-05-01": 13.2,
            "2025-06-01": 13.2,
            "2025-07-01": 13.2,
            "2025-08-01": 13.2,
            "2025-09-01": 13.2,
            "2025-10-01": 13.2,
            "2025-11-01": 13.2,
            "2025-12-01": 13.2
        },
        {
            "rough_layer": "放款APR",
            "detailed_layer": "主导小计",
            "2025-01-01": 13.19,
            "2025-02-01": 12.79,
            "2025-03-01": 15.6,
            "2025-04-01": 17.3,
            "2025-05-01": 15.6,
            "2025-06-01": 17.9,
            "2025-07-01": 11.6,
            "2025-08-01": 15.6,
            "2025-09-01": 15.6,
            "2025-10-01": 15.6,
            "2025-11-01": 15.6,
            "2025-12-01": 15.6
        },
        {
            "rough_layer": "管理余额",
            "detailed_layer": "合计",
            "2025-01-01": 246360750748.71,
            "2025-02-01": 246786650896.64,
            "2025-03-01": 651600000000,
            "2025-04-01": 651600000000,
            "2025-05-01": 651600000000,
            "2025-06-01": 651600000000,
            "2025-07-01": 651600000000,
            "2025-08-01": 651600000000,
            "2025-09-01": 651600000000,
            "2025-10-01": 651600000000,
            "2025-11-01": 651600000000,
            "2025-12-01": 651600000000
        },
        {
            "rough_layer": "管理余额",
            "detailed_layer": "自营",
            "2025-01-01": 70622720518.65,
            "2025-02-01": 70718345853.55,
            "2025-03-01": 127071866648.28,
            "2025-04-01": 173260812478.04,
            "2025-05-01": 209306827605.23,
            "2025-06-01": 243625192649.33,
            "2025-07-01": 257823346789.93,
            "2025-08-01": 387849991773.4,
            "2025-09-01": 374873914832.19,
            "2025-10-01": 371681779848.35,
            "2025-11-01": 366440260464.25,
            "2025-12-01": 366258728179.64
        },
        {
            "rough_layer": "管理余额",
            "detailed_layer": "助贷-主导",
            "2025-01-01": 52222438991.4,
            "2025-02-01": 52375662954.77,
            "2025-03-01": 192928133351.72,
            "2025-04-01": 146739187521.96,
            "2025-05-01": 110693172394.77,
            "2025-06-01": 76374807350.67,
            "2025-07-01": 62176653210.07,
            "2025-08-01": -67849991773.4,
            "2025-09-01": -54873914832.19,
            "2025-10-01": -51681779848.35,
            "2025-11-01": -46440260464.25,
            "2025-12-01": -46258728179.64
        },
        {
            "rough_layer": "管理余额",
            "detailed_layer": "助贷-辅助",
            "2025-01-01": 670431728.61,
            "2025-02-01": 598633280,
            "2025-03-01": 11600000000,
            "2025-04-01": 11600000000,
            "2025-05-01": 11600000000,
            "2025-06-01": 11600000000,
            "2025-07-01": 11600000000,
            "2025-08-01": 11600000000,
            "2025-09-01": 11600000000,
            "2025-10-01": 11600000000,
            "2025-11-01": 11600000000,
            "2025-12-01": 11600000000
        },
        {
            "rough_layer": "管理余额",
            "detailed_layer": "主导小计",
            "2025-01-01": 122845159510.05,
            "2025-02-01": 123094008808.32,
            "2025-03-01": 320000000000,
            "2025-04-01": 320000000000,
            "2025-05-01": 320000000000,
            "2025-06-01": 320000000000,
            "2025-07-01": 320000000000,
            "2025-08-01": 320000000000,
            "2025-09-01": 320000000000,
            "2025-10-01": 320000000000,
            "2025-11-01": 320000000000,
            "2025-12-01": 320000000000
        },
        {
            "rough_layer": "生息资产余额",
            "detailed_layer": "合计",
            "2025-01-01": 295994475299.9,
            "2025-02-01": 296448141718.91003,
            "2025-03-01": 0,
            "2025-04-01": 0,
            "2025-05-01": 0,
            "2025-06-01": 0,
            "2025-07-01": 0,
            "2025-08-01": 0,
            "2025-09-01": 0,
            "2025-10-01": 0,
            "2025-11-01": 0,
            "2025-12-01": 0
        },
        {
            "rough_layer": "生息资产余额",
            "detailed_layer": "自营",
            "2025-01-01": 69744087017.96,
            "2025-02-01": 69563652600.05,
            "2025-03-01": null,
            "2025-04-01": null,
            "2025-05-01": null,
            "2025-06-01": null,
            "2025-07-01": null,
            "2025-08-01": null,
            "2025-09-01": null,
            "2025-10-01": null,
            "2025-11-01": null,
            "2025-12-01": null
        },
        {
            "rough_layer": "生息资产余额",
            "detailed_layer": "助贷-主导",
            "2025-01-01": 51732595669.62,
            "2025-02-01": 52053052349.95,
            "2025-03-01": null,
            "2025-04-01": null,
            "2025-05-01": null,
            "2025-06-01": null,
            "2025-07-01": null,
            "2025-08-01": null,
            "2025-09-01": null,
            "2025-10-01": null,
            "2025-11-01": null,
            "2025-12-01": null
        },
        {
            "rough_layer": "生息资产余额",
            "detailed_layer": "助贷-辅助",
            "2025-01-01": 654257127.56,
            "2025-02-01": 580839734.48,
            "2025-03-01": null,
            "2025-04-01": null,
            "2025-05-01": null,
            "2025-06-01": null,
            "2025-07-01": null,
            "2025-08-01": null,
            "2025-09-01": null,
            "2025-10-01": null,
            "2025-11-01": null,
            "2025-12-01": null
        },
        {
            "rough_layer": "生息资产余额",
            "detailed_layer": "助贷小计",
            "2025-01-01": 52386852797.18,
            "2025-02-01": 52633892084.43,
            "2025-03-01": null,
            "2025-04-01": null,
            "2025-05-01": null,
            "2025-06-01": null,
            "2025-07-01": null,
            "2025-08-01": null,
            "2025-09-01": null,
            "2025-10-01": null,
            "2025-11-01": null,
            "2025-12-01": null
        },
        {
            "rough_layer": "日均生息资产余额",
            "detailed_layer": "合计",
            "2025-01-01": 300850127173.36,
            "2025-02-01": 296086314834.66,
            "2025-03-01": 0,
            "2025-04-01": 0,
            "2025-05-01": 0,
            "2025-06-01": 0,
            "2025-07-01": 0,
            "2025-08-01": 0,
            "2025-09-01": 0,
            "2025-10-01": 0,
            "2025-11-01": 0,
            "2025-12-01": 0
        },
        {
            "rough_layer": "日均生息资产余额",
            "detailed_layer": "自营",
            "2025-01-01": 71290823687.45,
            "2025-02-01": 69674916469.09,
            "2025-03-01": null,
            "2025-04-01": null,
            "2025-05-01": null,
            "2025-06-01": null,
            "2025-07-01": null,
            "2025-08-01": null,
            "2025-09-01": null,
            "2025-10-01": null,
            "2025-11-01": null,
            "2025-12-01": null
        },
        {
            "rough_layer": "日均生息资产余额",
            "detailed_layer": "助贷-主导",
            "2025-01-01": 52312034782.08,
            "2025-02-01": 51833067829.12,
            "2025-03-01": null,
            "2025-04-01": null,
            "2025-05-01": null,
            "2025-06-01": null,
            "2025-07-01": null,
            "2025-08-01": null,
            "2025-09-01": null,
            "2025-10-01": null,
            "2025-11-01": null,
            "2025-12-01": null
        },
        {
            "rough_layer": "日均生息资产余额",
            "detailed_layer": "助贷-辅助",
            "2025-01-01": 666187726.11,
            "2025-02-01": 618639204.56,
            "2025-03-01": null,
            "2025-04-01": null,
            "2025-05-01": null,
            "2025-06-01": null,
            "2025-07-01": null,
            "2025-08-01": null,
            "2025-09-01": null,
            "2025-10-01": null,
            "2025-11-01": null,
            "2025-12-01": null
        },
        {
            "rough_layer": "日均生息资产余额",
            "detailed_layer": "助贷小计",
            "2025-01-01": 52978222508.19,
            "2025-02-01": 52451707033.68,
            "2025-03-01": null,
            "2025-04-01": null,
            "2025-05-01": null,
            "2025-06-01": null,
            "2025-07-01": null,
            "2025-08-01": null,
            "2025-09-01": null,
            "2025-10-01": null,
            "2025-11-01": null,
            "2025-12-01": null
        },
        {
            "rough_layer": "日均生息资产余额IRR",
            "detailed_layer": "合计",
            "2025-01-01": 83.1,
            "2025-02-01": 82.93,
            "2025-03-01": 0,
            "2025-04-01": 0,
            "2025-05-01": 0,
            "2025-06-01": 0,
            "2025-07-01": 0,
            "2025-08-01": 0,
            "2025-09-01": 0,
            "2025-10-01": 0,
            "2025-11-01": 0,
            "2025-12-01": 0
        },
        {
            "rough_layer": "日均生息资产余额IRR",
            "detailed_layer": "自营",
            "2025-01-01": 16,
            "2025-02-01": 15.92,
            "2025-03-01": null,
            "2025-04-01": null,
            "2025-05-01": null,
            "2025-06-01": null,
            "2025-07-01": null,
            "2025-08-01": null,
            "2025-09-01": null,
            "2025-10-01": null,
            "2025-11-01": null,
            "2025-12-01": null
        },
        {
            "rough_layer": "日均生息资产余额IRR",
            "detailed_layer": "助贷-主导",
            "2025-01-01": 13.4,
            "2025-02-01": 13.39,
            "2025-03-01": null,
            "2025-04-01": null,
            "2025-05-01": null,
            "2025-06-01": null,
            "2025-07-01": null,
            "2025-08-01": null,
            "2025-09-01": null,
            "2025-10-01": null,
            "2025-11-01": null,
            "2025-12-01": null
        },
        {
            "rough_layer": "日均生息资产余额IRR",
            "detailed_layer": "助贷-辅助",
            "2025-01-01": 25.25,
            "2025-02-01": 25.25,
            "2025-03-01": null,
            "2025-04-01": null,
            "2025-05-01": null,
            "2025-06-01": null,
            "2025-07-01": null,
            "2025-08-01": null,
            "2025-09-01": null,
            "2025-10-01": null,
            "2025-11-01": null,
            "2025-12-01": null
        },
        {
            "rough_layer": "日均生息资产余额IRR",
            "detailed_layer": "助贷小计",
            "2025-01-01": 13.55,
            "2025-02-01": 13.53,
            "2025-03-01": null,
            "2025-04-01": null,
            "2025-05-01": null,
            "2025-06-01": null,
            "2025-07-01": null,
            "2025-08-01": null,
            "2025-09-01": null,
            "2025-10-01": null,
            "2025-11-01": null,
            "2025-12-01": null
        }
    ]
    const columns: any = autoColumns(data)
    return <Layout className={styles.page}>
        <Header className={styles.page__header}>
            <Button>
                {'返回'}
            </Button>
            <div className={styles['page__header--space']} style={{ flex: 1 }} />
            <Button type='primary'>
                {'导出'}
            </Button>
        </Header>
        <Content className={styles.page__section}>
            <Table
                dataSource={data}
                columns={columns}
                scroll={{
                    x: 'max-content',
                    y: 'max-content'
                }}
                bordered
                pagination={false}
                sticky
            />
        </Content>
    </Layout>
}

export default incomeStatist